#include<bits/stdc++.h>
using namespace std;
const int N = 1e7 + 10;
#define int long long
int a[N];
int fa[N];
const int mod = 1048576;
int find(int x) {
    if (x != fa[x]) fa[x] = find(fa[x]);
    return fa[x];
}
signed main() {
    for (int i = 0;i < N;i++) {
        fa[i] = i;
        a[i] = -1;
    }
    int T;
    cin >> T;
    while (T--) {
        int op, x;
        cin >> op >> x;
        if (op == 1) {
            int z = x % mod;

            if (a[z] == -1) {
                a[z] = x;
                fa[z] = (z + 1) % mod;
            }
            else {
                z = find(z);
                if (a[z] == -1) {
                    a[z] = x;
                    fa[z] = (z + 1) % mod;
                }
            }

        }
        else cout << a[x % mod] << endl;
    }
}